//
// Created by Yucheng on 6/2/17.
//

#include "CppUTest/MemoryLeakDetectorMallocMacros.h"
#include "CppUTest/MemoryLeakDetectorNewMacros.h"
#include "cpputest.hpp"
#include "CppUTest/TestHarness.h"

std::string a = "123";

TEST_GROUP(misc_httpclient)
{
    TestApp app;
    std::string b = "kk";
    
    void setup()
    {
        app.setup();
    }
    
    void teardown()
    {
    }
};

TEST(misc_httpclient, foo)
{
    b += "56";
    std::cout << "a = " << a << std::endl;
    STRCMP_EQUAL(a.c_str(), "123");
}

TEST(misc_httpclient, simple)
{
    std::string clientError = "";
    diylane::http::client::AcquiredWorker client(&client::Pool::singleton(), clientError);
    diylane::http::Request req;
    diylane::http::Response resp;
    req.url = "http://www.baidu.com";
    req.cookieJar.set(new diylane::http::Cookie("abc", "zzzzz"));
    req.cookieJar.set(new diylane::http::Cookie("PTOKEN", "A428DB28EAE41DF7BE9F34329B2D5238"));
    if (!client.unwrap()->doRequest(&req, resp)) {
        std::cout << "error: " << resp.error << std::endl;
    }
}
